﻿// CheckProjectPane.cpp: 实现文件
//

#include "stdafx.h"
#include "zChecker.h"
#include "CheckProjectPane.h"


// CCheckProjectPane

IMPLEMENT_DYNAMIC(CCheckProjectPane, CDockablePane)

CCheckProjectPane::CCheckProjectPane()
{

}

CCheckProjectPane::~CCheckProjectPane()
{
}


BEGIN_MESSAGE_MAP(CCheckProjectPane, CDockablePane)
	ON_WM_CREATE()
	ON_WM_SIZE()
	ON_WM_CONTEXTMENU()
END_MESSAGE_MAP()



// CCheckProjectPane 消息处理程序




int CCheckProjectPane::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CDockablePane::OnCreate(lpCreateStruct) == -1)
		return -1;

	// TODO:  在此添加您专用的创建代码
	CRect rectDummy;
	rectDummy.SetRectEmpty();
	// 创建视图: 
	const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | /*TVS_LINESATROOT |*/ TVS_HASBUTTONS | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TVS_CHECKBOXES | TVS_NOSCROLL;
	//const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TVS_NOSCROLL;

	//if (!m_tree.Create(dwViewStyle, rectDummy, this, 2))
	if (!m_tree.Create(0, rectDummy, this, 2))
	{
		TRACE0("未能创建类视图\n");
		return -1;      // 未能创建
	}

	//InitTree();
	AdjustLayout();

	return 0;
}


void CCheckProjectPane::OnSize(UINT nType, int cx, int cy)
{
	CDockablePane::OnSize(nType, cx, cy);

	// TODO: 在此处添加消息处理程序代码
	AdjustLayout();
}

void CCheckProjectPane::AdjustLayout()
{
	if (GetSafeHwnd() == NULL)
	{
		return;
	}

	CRect rectClient;
	GetClientRect(rectClient);

	int cyTlb = 0;//m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy;

	//m_wndToolBar.SetWindowPos(NULL, rectClient.left, rectClient.top, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER);
	//m_tree.SetWindowPos(NULL, rectClient.left, rectClient.top + cyTlb + 1, rectClient.Width() - 2, rectClient.Height() - cyTlb - 2, SWP_NOACTIVATE | SWP_NOZORDER);
	m_tree.SetWindowPos(NULL, rectClient.left, rectClient.top + cyTlb, rectClient.Width(), rectClient.Height() - cyTlb, SWP_NOACTIVATE | SWP_NOZORDER);
	//m_tree.MoveWindow(rectClient.left, rectClient.top + cyTlb, rectClient.Width(), rectClient.Height() - cyTlb);

}

void CCheckProjectPane::InitTree()
{
	HTREEITEM  m_hRoot = m_tree.InsertItem(_T("地图"), 0, 0);
	//HTREEITEM  m_hRoot = m_tree.InsertItem(_T("地图"), 1, 1);
	//m_tree.SetItemState(m_hRoot, TVIS_BOLD, TVIS_BOLD);
	m_tree.SetItemState(m_hRoot, INDEXTOSTATEIMAGEMASK(0), TVIS_STATEIMAGEMASK);
	m_tree.SetCheck(m_hRoot, 1);
	m_tree.Expand(m_hRoot, TVE_EXPAND);

	HTREEITEM hClass = m_tree.InsertItem(_T("CFakeAboutDlg"), 1, 1, m_hRoot);
	m_tree.InsertItem(_T("CFakeAboutDlg()"), 3, 3, hClass);

	m_tree.Expand(m_hRoot, TVE_EXPAND);

	hClass = m_tree.InsertItem(_T("CFakeApp"), 1, 1, m_hRoot);
	m_tree.InsertItem(_T("CFakeApp()"), 3, 3, hClass);
	m_tree.InsertItem(_T("InitInstance()"), 3, 3, hClass);
	m_tree.InsertItem(_T("OnAppAbout()"), 3, 3, hClass);

	hClass = m_tree.InsertItem(_T("CFakeAppDoc"), 1, 1, m_hRoot);
	m_tree.InsertItem(_T("CFakeAppDoc()"), 4, 4, hClass);
	m_tree.InsertItem(_T("~CFakeAppDoc()"), 3, 3, hClass);
	m_tree.InsertItem(_T("OnNewDocument()"), 3, 3, hClass);

	hClass = m_tree.InsertItem(_T("CFakeAppView"), 1, 1, m_hRoot);
	m_tree.InsertItem(_T("CFakeAppView()"), 4, 4, hClass);
	m_tree.InsertItem(_T("~CFakeAppView()"), 3, 3, hClass);
	m_tree.InsertItem(_T("GetDocument()"), 3, 3, hClass);
	m_tree.Expand(hClass, TVE_EXPAND);

	hClass = m_tree.InsertItem(_T("CFakeAppFrame"), 1, 1, m_hRoot);
	m_tree.InsertItem(_T("CFakeAppFrame()"), 3, 3, hClass);
	m_tree.InsertItem(_T("~CFakeAppFrame()"), 3, 3, hClass);
	m_tree.InsertItem(_T("m_wndMenuBar"), 6, 6, hClass);
	m_tree.InsertItem(_T("m_wndToolBar"), 6, 6, hClass);
	m_tree.InsertItem(_T("m_wndStatusBar"), 6, 6, hClass);

	hClass = m_tree.InsertItem(_T("Globals"), 2, 2, m_hRoot);
	m_tree.InsertItem(_T("theFakeApp"), 5, 5, hClass);
	m_tree.Expand(hClass, TVE_EXPAND);
}

void CCheckProjectPane::OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/)
{
	// TODO: 在此处添加消息处理程序代码
}

RESULTCODE CCheckProjectPane::AddDataSource(ck::DataSource* pDataSource)
{
	return m_tree.AddDataSource(pDataSource);
}